package com.cjkj.system.api.factory;

import com.cjkj.common.core.web.domain.AjaxResult;
import com.cjkj.system.api.RemoteTJ02HealthReportService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 设备降级处理
 */
@Component
public class RemoteTJ02HealthReportFallbackFactory implements FallbackFactory<RemoteTJ02HealthReportService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteLogFallbackFactory.class);
    @Override
    public RemoteTJ02HealthReportService create(Throwable cause) {
        log.error("系统服务调用失败:{}", cause.getMessage());
        return new RemoteTJ02HealthReportService() {
            @Override
            public AjaxResult getHeartReports(Long visitNo) {
                return AjaxResult.error("查询心率报告失败！");
            }

            @Override
            public AjaxResult getTemperatureReports(Long visitNo) {
                return AjaxResult.error("查询体温报告失败！");
            }

            @Override
            public AjaxResult getSpo2Reports(Long visitNo) {
                return AjaxResult.error("查询血氧报告失败！");
            }

            @Override
            public AjaxResult requestPrintReportData(String visitNos, String reportItems) {
                return AjaxResult.error("报告数据查询失败！");
            }
        };
    }
}